home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / view_a_file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  3.1 KB  |  139 lines

  1. #include "bbs.h"
  2.  
  3. extern int LineCount;
  4. extern char Command[6][40];
  5. extern char Conference_Location[];
  6. extern BOOL GET_BIT(int bitnum);
  7. int View_A_File(void)
  8. {
  9. int stat,x;
  10. char path[255],final[255],Fn[100],clog[100];
  11. FILE *f,*ft=NULL;
  12. int drivenum=1;
  13. char cmt[100];
  14. gnsflag=0;
  15. LineCount=0;
  16. AEPutStr("\r\n");
  17. if(MaxDirs==0)
  18.     {
  19.     AEPutStr("No files available in this conference.\r\n\r\n");
  20.     return(FAILURE);
  21.     }
  22.  
  23. stat=CommandSplit();
  24. gnsflag=CheckForNS(Command[stat-1]);
  25.  
  26. if(stat>1) { strcpy(Fn,Command[1]); goto Some; }
  27. AEPutStr("Enter filename of file to view? ");
  28. stat=LineInput("",Fn,40,KEYBOARD_TIMEOUT);
  29. if(stat<0) { return(NO_CARRIER); }
  30. if(strlen(Fn)==0) { AEPutStr("\r\n"); return(SUCCESS); }
  31.  
  32.  
  33. Some:
  34. strcpy(path,Conference_Location);
  35. if(path[strlen(path)-1]=='/') path[strlen(path)-1]='\0';
  36. goto SkipMe;
  37. SkipToIt:
  38.     sprintf(GSTR3,"File %s not found.\r\n\r\n",path);
  39.     AEPutStr(GSTR3);
  40.     return(FAILURE);
  41.  
  42. SkipMe:
  43.  
  44. if(GET_BIT(ACS_SYSOP_VIEW)&&(Command[0][1]=='S'||Command[0][1]=='s'))
  45.     {
  46.      if(FindAssign(Fn)) { strcpy(path,Fn); goto SkipToIt; }
  47.     f = fopen(Fn,"r");
  48.     if(f==NULL)
  49.         {
  50.         strcpy(path,Fn); 
  51.         goto SkipToIt;
  52.         }
  53.      fclose(f);
  54.     sprintf(GSTR3,"\tSysopView %s\n",Fn);
  55.     CallersLog(GSTR3);
  56.     strcpy(final,Fn);
  57.     goto Skipit;
  58.     }
  59.  
  60. for(x=0;x<strlen(Fn);++x)
  61.     {
  62.     if(Fn[x]==':' || Fn[x]=='/' || Fn[x]=='*' || Fn[x]=='@')
  63.         {
  64.         AEPutStr("You may not include any special symbols\r\n\r\n");
  65.          return(FAILURE);
  66.         }
  67.     }
  68.  
  69.  
  70.   sprintf(path,"DLPATH.%d",drivenum++);
  71. while(GetFromConf(CN-1,path,path))
  72.     {
  73.        strcpy(final,path);
  74.       strcat(final,Fn);
  75.       Skipit:
  76.         ft = fopen(final,"r");
  77.         if(ft!=NULL)
  78.             {
  79. /**************** ADDED SECURITY FOR VS ******************
  80.     CODE REVISION BY JOSEPH HODGE
  81.  *********************************************************/
  82.                strcpy(cmt,GetFileComment(final));
  83.                if(!strnicmp(cmt,"Restricted",10))
  84.                {
  85.                  AEPutStr("\n\rAttempt to read RESTRICTED file denied\n\r");
  86.                  AEPutStr("Updating Callerslog\r\n");
  87.                  sprintf(clog,"\t\tAttempt to read RESTRICTED file [%s]\n",Fn);
  88.                  CallersLog(clog);
  89.                  fclose(ft); return(FAILURE);
  90.                }
  91.             while(fgets(GSTR3,1000,ft)!=NULL)
  92.                {
  93.                 GSTR3[1000]='\0';
  94.                 if(GSTR3[0]>128||GSTR3[1]>128||GSTR3[2]>128)
  95.                     {
  96.                     fclose(ft);
  97.                     AEPutStr("\r\nThis file is not a text file.\r\n\r\n");
  98.                     return(FAILURE);
  99.                     }
  100.                     AEPutStr(GSTR3);
  101.                     AEPutStr("\r");
  102.                     if(stat=CheckForPause())
  103.                         {
  104.                         fclose(ft);
  105.                         AEPutStr("\r\n");
  106.                         return(stat);
  107.                         }
  108.                     if(CheckInput())
  109.                         {
  110.                         stat=ReadChar(1L);
  111.                         switch(stat)
  112.                             {
  113.                             case '\023': /* Pause */
  114.                                 stat=ReadChar(KEYBOARD_TIMEOUT);
  115.                                 if(stat<0)
  116.                                     {
  117.                                     fclose(ft);
  118.                                     return(NO_CARRIER);
  119.                                     }
  120.                                 break;
  121.                             case '\003': /* ^C */
  122.                                 AEPutStr("**Break\r\n\r\n");
  123.                                 fclose(ft);
  124.                                 return(FAILURE);
  125.                             }
  126.                         }
  127.                 } 
  128.             fclose(ft); 
  129.             AEPutStr("\r\n\r\n");
  130.             return(SUCCESS);
  131.             }
  132.      if(ft!=NULL) break;
  133.   sprintf(path,"DLPATH.%d",drivenum++);
  134.  
  135.     } 
  136. AEPutStr("File not found.\r\n\r\n");
  137. return(SUCCESS);
  138. }
  139.